<template lang="pug">
  Card.log-con
    Tabs(:animated="false",@on-click='handleTabActive')
       TabPane(v-for="(item, index) in tabData",:key="index",:label='item.label',:name='item.component')
    component(:is='tabPaneComponent',
      :collectBtnStatus="$route.meta['采集日志']['/log_centor/collection_Download'] ? true:false",
      :operateBtnStatus="$route.meta['操作日志']['/log_centor/operation_Download']? true:false",
      :interfaceBtnStatus="$route.meta['接口日志']['/log_centor/interface_Download']? true:false",
      :serverBtnStatus="$route.meta['交互服务日志']['/log_centor/interactive_Download']? true:false")
</template>

<script>
import logCollect from './components/LogCollect'
import logOperate from './components/LogOperate'
import logInterface from './components/LogInterface'
import logServer from './components/LogServer'

export default {
  name: 'Log',
  components: { logCollect, logOperate, logInterface, logServer },
  data() {
    return {
      tabData: [],
      tabPaneComponent: ''
    }
  },
  created() {
    Object.keys(this.$route.meta).forEach(item => {
      let tabItem = {}
      if (item === '采集日志') tabItem = { label: item, component: 'logCollect' }
      if (item === '操作日志') tabItem = { label: item, component: 'logOperate' }
      if (item === '接口日志') tabItem = { label: item, component: 'logInterface' }
      if (item === '交互服务日志') tabItem = { label: item, component: 'logServer' }
      this.tabData.push(tabItem)
    })
    this.tabPaneComponent = this.tabData[0].component
  },
  methods: {
    handleTabActive(name) {
      this.tabPaneComponent = name
    }
  }
}
</script>